//
//  ZJSuperController.m
//  SoundRecording
//
//  Created by zhengju on 2017/11/29.
//  Copyright © 2017年 郑俱. All rights reserved.
//

#import "ZJSuperController.h"

@interface ZJSuperController ()

@end

@implementation ZJSuperController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
- (UIButton *)leftBtn{
    if (_leftBtn == nil) {
        _leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 50, 30)];
        
        // [_leftBtn setTitle:@"返回" forState:UIControlStateNormal];
        [_leftBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //        [_leftBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        
        UIBarButtonItem *leftBarBtn = [[UIBarButtonItem alloc] initWithCustomView:_leftBtn];
        self.navigationItem.leftBarButtonItem = leftBarBtn;
    }
    return _leftBtn;
}
- (UIButton *)backBtn{
    if (_backBtn == nil) {
        _backBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
        
        [_backBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_backBtn setImage:SET_IMAGE(@"back-arrow") forState:UIControlStateNormal];
        _backBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        _backBtn.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15];
        UIBarButtonItem *leftBackBarBtn = [[UIBarButtonItem alloc] initWithCustomView:_backBtn];
        self.navigationItem.leftBarButtonItem = leftBackBarBtn;
    }
    return _backBtn;
}
- (UIButton *)rightBtn{
    
    if (_rightBtn == nil) {
        
        CGFloat Width = 40;
        
        _rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, Width, Width)];
        
        [_rightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
        UIBarButtonItem *rightBarBtn = [[UIBarButtonItem alloc] initWithCustomView:_rightBtn];
 
        self.navigationItem.rightBarButtonItem = rightBarBtn;
    }
    return _rightBtn;
}
#pragma mark - backAction返回
- (void)backAction
{
    if ((self.navigationController.presentedViewController || self.navigationController.presentingViewController)&&self.childViewControllers.count == 1) {
        [self.navigationController dismissViewControllerAnimated:YES completion:nil];
       
    }else{
        
        [self.navigationController popViewControllerAnimated:YES];
    }
    
}
@end
